/*
 * Title:        CloudScheduler Toolkit
 * Description:  a Toolkit for Modeling and Simulation of Job Scheduling and Resource Provisioning in Cloud System
 * Licence:      GPL - http://www.gnu.org/copyleft/gpl.html
 * Author:       Fuhui Wu
 *
 * Copyright (c) 2013-2014, The National University of Defense Technology, China
 */

package org.nudt.jCloud.example.basic;

import org.nudt.jCloud.infrastructure.HomegeneousCluster;
import org.nudt.jCloud.infrastructure.SlotType;
import org.nudt.jCloud.jobScheduler.AFCFSScheduler;
import org.nudt.jCloud.jobScheduler.JobScheduler;
import org.nudt.jCloud.resourceManager.GeneralShareStateRM;
import org.nudt.jCloud.resourceManager.ResManager;
import org.nudt.jCloud.resourceScaler.ResourceScaler;
import org.nudt.jCloud.resourceScaler.ThresholdScaler;
import org.nudt.jCloud.simulation.CloudSchedSIM;
import org.nudt.jCloud.simulation.SIMTag;
import org.nudt.jCloud.simulation.User;
import org.nudt.jCloud.simulation.UserBroker;
import org.nudt.jCloud.workload.GangWLGen;
import org.nudt.jCloud.workload.Workload;
import org.nudt.jCloud.workload.WorkloadGenerator;

public class GangExample {

	public static void main(String[] args) {
		CloudSchedSIM.init("GangExample");
		HomegeneousCluster homeCluster = new HomegeneousCluster(10, 1000, 3, 4000, 1000, 200000);
		ResManager monolithicRM = new GeneralShareStateRM("Monolithic", homeCluster);
		UserBroker userBroker1 = new UserBroker("UserBroker1", SIMTag.RM_MODE_S);
		ResourceScaler resourceScaler = new ThresholdScaler(5, 0.5);
		SlotType slotType = new SlotType(1, 1000, 250, 0);
		WorkloadGenerator wlGen = new GangWLGen(1000, 100, 50, 0.5, 30, slotType);
		Workload wl = wlGen.generate(0);
		JobScheduler jobScheduler = new AFCFSScheduler("FCFS-Gang");
		userBroker1.init(jobScheduler, resourceScaler);
		User user = new User("user", wl);
		userBroker1.addUser(user);		
		CloudSchedSIM.addRM(monolithicRM);
		CloudSchedSIM.addUserBroker(userBroker1);
		CloudSchedSIM.startSimulation();
		
	}

}
